package com.aya.aop.custom.intro.advisor;

import com.aya.aop.custom.intro.MyIntroductionInterceptor;
import org.springframework.aop.support.DefaultIntroductionAdvisor;
import org.springframework.util.AntPathMatcher;
import org.springframework.util.PathMatcher;

import javax.annotation.Resource;

//@Service
public class IntroPathAdvisor extends DefaultIntroductionAdvisor {
    public IntroPathAdvisor(MyIntroductionInterceptor introductionInterceptor) {
        super(introductionInterceptor);
    }

    @Resource
    IntroBeforeAdvisor introBeforeAdvisor;

    PathMatcher pathMatcher = new AntPathMatcher(",");

    private String pattern = "com.aya.aop.custom.intro.point.*";
    /**
     * 匹配规则。
     * 或者写死类型都行
     *
     * @param clazz
     * @return
     */
    @Override
    public boolean matches(Class<?> clazz) {
        return pathMatcher.match(pattern, clazz.getName());
    }
}
